/**
 * Copyright 2011 Marco Berri - marcoberri@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *
 */
package com.mbfasttrack.model;

import java.util.Date;
import java.util.ArrayList;
import java.util.List;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * @author Marco Berri marcoberri@gmail.com http://tecnicume.blogspot.com
 */
@Document
public class Group implements Base {

    @Id
    @Indexed
    private String id;
    @Indexed(unique = true)
    private String slug;
    private String name;
    private String description;
    private Date date = new Date(System.currentTimeMillis());
    private Boolean publicview;
    @DBRef
    private List<User> userLink = new ArrayList();
    @DBRef
    private List<User> userAdminLink = new ArrayList();
    @DBRef
    private User user;
    @DBRef
    private List<Media> media = new ArrayList();
    @DBRef
    private List<Track> trackLink = new ArrayList();
    private String activity;
    @DBRef
    private List<Tag> tagsLink = new ArrayList();
    @Transient
    private String tags;

    /**
     *
     */
    public Group() {
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }

    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * @return the date
     */
    public Date getDate() {
        return date;
    }

    /**
     * @param date the date to set
     */
    public void setDate(Date date) {
        this.date = date;
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * @return the slug
     */
    public String getSlug() {
        return slug;
    }

    /**
     * @param slug the slug to set
     */
    public void setSlug(String slug) {
        this.slug = slug;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the publicview
     */
    public Boolean getPublicview() {
        return publicview;
    }

    /**
     * @param publicview the publicview to set
     */
    public void setPublicview(Boolean publicview) {
        this.publicview = publicview;
    }

    /**
     * @return the tags
     */
    public String getTags() {
        return tags;
    }

    /**
     * @param tags the tags to set
     */
    public void setTags(String tags) {
        this.tags = tags;
    }

    /**
     * @return the media
     */
    public List<Media> getMedia() {
        return media;
    }

    /**
     * @param media
     */
    public void addMedia(Media media) {
        if (this.getMedia() == null) {
            this.setMedia(new ArrayList<Media>());
        }

        this.getMedia().add(media);
    }

    /**
     * @param media the media to set
     */
    public void setMedia(List<Media> media) {
        this.media = media;
    }

    /**
     * @return the activity
     */
    public String getActivity() {
        return activity;
    }

    /**
     * @param activity the activity to set
     */
    public void setActivity(String activity) {
        this.activity = activity;
    }

    /**
     * @return the tagsLink
     */
    public List<Tag> getTagsLink() {
        return tagsLink;
    }

    /**
     * @param tagsLink the tagsLink to set
     */
    public void setTagsLink(List<Tag> tagsLink) {

        if (this.tagsLink == null || this.tagsLink.isEmpty()) {
            this.tagsLink = new ArrayList<Tag>();
        }

        this.tagsLink = tagsLink;
    }

    /**
     *
     * @param t
     */
    public void addTagLink(Tag t) {

        if (this.tagsLink == null || this.tagsLink.isEmpty()) {
            this.tagsLink = new ArrayList<Tag>();
        }
        this.tagsLink.add(t);
    }

    /**
     *
     * @param u
     */
    public void addUserLink(User u) {

        this.getUserLink().add(u);

    }

    public void addTrackLink(Track t) {
        if (this.getTrackLink() == null) {
            this.trackLink = new ArrayList();
        }

        this.getTrackLink().add(t);
    }

    /**
     *
     * @param u
     */
    public void addUserAdminLink(User u) {

        this.getUserAdminLink().add(u);

    }

    /**
     * @return the userLink
     */
    public List<User> getUserLink() {
        return userLink;
    }

    /**
     * @param userLink the userLink to set
     */
    public void setUserLink(List<User> userLink) {
        this.userLink = userLink;
    }

    /**
     * @return the userAdminLink
     */
    public List<User> getUserAdminLink() {
        return userAdminLink;
    }

    /**
     * @param userAdminLink the userAdminLink to set
     */
    public void setUserAdminLink(List<User> userAdminLink) {
        this.userAdminLink = userAdminLink;
    }

    /**
     * @return the trackLink
     */
    public List<Track> getTrackLink() {
        return trackLink;
    }

    /**
     * @param trackLink the trackLink to set
     */
    public void setTrackLink(List<Track> trackLink) {
        this.trackLink = trackLink;
    }
}
